import service from "@/utils/request.js";

//根据状态获取猪小妹餐厅的菜品类别
export function apiGetRestaurantCategoriesByStatus(status) {
	return service.get('/restaurant/categories/'+status);
}

//根据状态获取猪小妹餐厅的菜品信息
export function apiGetRestaurantDishesByStatus(status) {
	return service.get('/restaurant/dishes/'+status);
}

//修改猪小妹餐厅菜品状态（上下架）
export function apiPutRestaurantDishesStatus(data = {}) {
	return service.put('/restaurant/changeDishesStatus', data, {useFormEncoded:'json'});
}

//获取猪小妹餐厅的所有菜品类别
export function apiGetRestaurantAllCategories() {
	return service.get('/restaurant/categories');
}

//猪小妹餐厅新增菜品
export function apiPostRestaurantDish(data = {}) {
	return service.post('/restaurant/addDish', data, {useFormEncoded:'json'});
}

//根据菜品id获取猪小妹餐厅的菜品信息
export function apiGetRestaurantDishById(id) {
	return service.get('restaurant/dish/'+id);
}

// 修改猪小妹餐厅的菜品信息
export function apiPutRestaurantDish(data = {}) {
	return service.put('/restaurant/editDish', data, {useFormEncoded:'json'});
}

// 根据id删除猪小妹餐厅的菜品
export function apiDeleteDish(id) {
	return service.delete('/restaurant/deleteDish/'+id);
}

// 猪小妹餐厅新增类别
export function apiPostRestaurantCategory(data = {}) {
	return service.post('/restaurant/addCategory', data, {useFormEncoded:'json'});
}

// 根据类别状态获取类别及其下面的菜品
export function apiGetRestaurantCategoryAndDishes(status) {
	return service.get('/restaurant/categoryAndDishes/'+status);
}
// 根据菜品类别名称查询类别下是否有在售菜品，返回在售菜品id
export function apiGetRestaurantDishOnSaleByCategoryName(categoryName) {
	return service.get('/restaurant/dishOnSaleByCategoryName/'+categoryName);
}
// 根据菜品类别名称查询类别下是否有未在售菜品，返回在售菜品id
export function apiGetRestaurantDishOnNoSaleByCategoryName(categoryName) {
	return service.get('/restaurant/dishOnNoSaleByCategoryName/'+categoryName);
}

// 根据status改变菜品类别状态，同时改变该类别下的dish的status。
export function apiPutRestaurantCategoryAndDishesStatus(status, data={}) {
	// console.log("status", status)
	return service.put('/restaurant/changeCategoryAndDishesStatus/'+status, data, {useFormEncoded:'json'});
}

// 根据类别名获取类别信息
export function apiGetRestaurantCatetoryInfoByCategoryName(categoryName) {
	return service.get('/restaurant/getRestaurantCatetoryInfoByCategoryName/'+categoryName);
}

// 修改菜品类别信息
export function apiPutRestaurantCategory(data={}) {
	return service.put('/restaurant/putRestaurantCategory', data, {useFormEncoded:'json'});
}

// 删除菜品类别
export function apiDeleteCategoryByName(category) {
	return service.delete('/restaurant/deleteCategoryByName/'+category);
}

// 用户菜品下单
export function apiRestaurantNewOrder(data){
	return service.post('/restaurant/newOrder', data, {useFormEncoded:'json'});
}

// 根据orderNo获取订单信息
export function apiRestaurantOrderInfo(orderNo){
	return service.get('/restaurant/restaurantOrderInfo/'+orderNo);
}

// 根据订单状态获取当前用户与对象用户的所有订单
export function apiRestaurantOrdersByStatus(status) {
	return service.get('/restaurant/restaurantOrders/'+status);
}

// 根据订单状态获取当前用户与对象用户的所有订单数量
export function apiRestaurantOrdersCountByStatus(status) {
	return service.get('/restaurant/restaurantOrdersCount/'+status);
}

// 根据订单号改变订单状态
export function apiRestaurantEditOrderStatus(data) {
	return service.put('/restaurant/editRestaurantOrder', data, {useFormEncoded:'json'})
}